

import request from '@/router/axios'
import {
  allStatus, chezhan_bukuan_status,
  fenExYuangettoFixed, getAudit_state, getchezhan_bukuan_status, getIs_sup_payment,
  getLineName, getMappingStatus, getMappingStatusArray,
  getNoticeStates,
  getStationName, getSupp_state_status,
  noticeStates, supp_state_status
} from "@/api/subwayRat/commonCheck";


export function getOption() {
  return {
    emptyBtn: false,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    border: true,
    index: true,
    viewBtn:false,
    indexLabel: '序号',
    page: true,
    align: 'center',
    menuWidth: 150,
    menuAlign: 'center',
    selection: true,
    reserveSelection: false,
    column: [
      {label: "线路",
        width: 100,
        prop: "lineCode",
        search:false,
        hide:true,
        searchslot:true,
        formatter: function(row, value , label, column){
        return getLineName(value);
      }
      },
      {
        label: '站点',
        width: 130,
        prop: 'stationCode',
        type: 'select',
        // cascaderItem: ["tvmCode"],
        search: true,
        searchslot:true,
        formatter: function(row, value , label, column){
          return getStationName(row.lineCode,value);
        }
      },
      {
        label: 'TVM编号',
        prop: 'tvmCode',
        search: true
      },
      {label: "收入日期", prop: "recordTime",type:'date',
        width: 90,format:'yyyy-MM-dd',valueFormat:'yyyy-MM-dd',search:true},
      {label: "实点金额", prop: "actualAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'actualAmount');
        }},
      {label: "系统金额", prop: "systemAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'systemAmount');
        }},
      {label: "差异金额", prop: "differenceAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'differenceAmount');
        }},
      {label: "售票员",width: 120, prop: "conductorPersonName",type:'select',search:false,searchslot:true},
      {label: "售票员工号", width: 130,prop: "conductorPersonCode"},
      {label: "通知状态", prop: "noticeState",type:'select',search:false,hide:true,dicData:noticeStates(),formatter: function(row, value , label, column){
          return getNoticeStates(value);
        }},
      {label: "下发状态", prop: "sendStatus",type:'select',search:true,dicData:getMappingStatusArray('conductor_invalidticket_status')
        ,formatter: function(row, value , label, column){
          return getMappingStatus('conductor_invalidticket_status',value);
        }},
      {label: "下发时间", prop: "sendTime",type:'date',
        width: 160,format:'yyyy-MM-dd HH:mm:ss',valueFormat:'yyyy-MM-dd HH:mm:ss'},
      {label: "审批状态",width: 120, prop: "auditSate",type:'select',search:true,
        dicUrl: '/admin/dict/type/audit_sate',
        formatter :function(row, value , label, column){
          return row.auditSate;
        }},
      {
        hide:true,
        width: 120,
        "type": "select",
        "label": "数据来源",
        "prop": "dataSource",
        search:false,
        formatter:function(row, value , label, column){
          return value==1?'人工添加':value==0?'审核主页加入':'';
        },
        dicData: [{
          label: '审核主页加入',
          value: '0'
        }, {
          label: '人工添加',
          value: '1'
        }]
      },
      {
        width: 120,
        label: "补款状态",
        prop: "isSupPayment",
        type: 'select',
        search: true,
        hide:false,
        dicData: chezhan_bukuan_status(),
        formatter: function (row, v) {
          return getchezhan_bukuan_status(v);
        }
      },


      {label: "最晚回复期限（天）",hide:true,width: 160, prop: "replyPeriod"},
      {label: "车站申诉原因", prop: "appealReason", width:180},
      {
        label: '申诉收益回复',
        prop: 'appealReply',
        // width:'250',
        labelWidth:130,
        type:'textarea',
        disabled:true,
      },{
        label: '站长审核意见',
        prop: 'auditStationOpinion',
        // width:'250',
        labelWidth:130,
        type:'textarea',
        disabled:true,
      },{
        label: '车间票务专业审核意见',
        prop: 'auditWorkshopOpinion',
        // width:'250',
        labelWidth:130,
        type:'textarea',
        disabled:true,
      },{
        label: '部门票务专业审核意见',
        prop: 'auditDeptOpinion',
        // width:'250',
        labelWidth:130,
        type:'textarea',
        disabled:true,
      },
      {label: "车站备注", prop: "remark", width:180},
      // {label: "收益审核意见", prop: "appealReply", width:180},
      {label: "审批人", prop: "approverName"},
      {label: "审批时间", width: 120,type:'date', format:'yyyy-MM-dd',valueFormat:'yyyy-MM-dd', prop: "approverTime"},
      {label: "附件", prop: "fileUrl",hide:true}
    ]
  }
}

export const tableOptionAdd = {
  border: true,
  index: true,
  align: "center",
  labelWidth: 160,
  submitBtn:false,
  emptyBtn:false,
  'column': [
    {
      label: "线路",
      prop: "lineCode",
      type: "select",
      labelWidth: 130,
      formslot: true,
      rules: [
        {
          required: true,
          message: "请选择线路",
          trigger: "blur"
        }
      ]
    },
    {
      label: "站点",
      prop: "stationCode",
      type: "select",
      labelWidth: 130,
      formslot: true,
      rules: [
        {
          required: true,
          message: "请选择站点",
          trigger: "blur"
        }
      ]
    }, {
      label: "售票员",
      prop: "conductorPersonName",
      labelWidth: 130,
      type: "select",
      formslot: true,
      rules: [
        {
          required: true,
          message: "请选择或者输入售票员",
          trigger: "blur"
        }
      ]
    },
    {
      label: "售票员工号",
      prop: "conductorPersonCode",
      labelWidth: 130,
      type: "select",
      formslot: true,
      rules: [
        {
          required: true,
          message: "请选择或者输入售票员工号",
          trigger: "blur"
        }
      ]
    },
    {
      label: "TVM编号",
      prop: "tvmCode",
      labelWidth: 130,
      type: "select",
      formslot: true,
      rules: [
        {
          required: true,
          message: "请选择或者输入TVM编号",
          trigger: "blur"
        }
      ]
    },
    {
	  label: "收入日期", 
	  labelWidth: 130,
	  prop: "recordTime",
	  type:'date',
      valueFormat:'yyyy-MM-dd',
	  search:true,
      rules: [
        {
          required: true,
          message: "请选择收入日期",
          trigger: "blur"
        }
      ],
    },
    {
      label: "差异金额",
      "type": "number",
      precision: 2,
      labelWidth: 130,
      prop: "differenceAmount",
      rules: [
        {
          required: true,
          message: "请输入差异金额",
          trigger: "blur"
        }
      ],
    },
    {
      label: "差异描述",
      type: "textarea",
      labelWidth: 130,
      prop: "differenceDescription"
    }
  ]
}


export function getTvmPiaoKuanCYTZOption() {
  return {
    emptyBtn: false,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    border: true,
    index: true,
    indexLabel: '序号',
    page: true,
    align: 'center',
    menuWidth: 150,
    menuAlign: 'center',
    selection: true,
    reserveSelection: false,
    height: 450,
    column: [
      {label: "收入日期", prop: "recordTime",type:'date',format:'yyyy-MM-dd',valueFormat:'yyyy-MM-dd'},
      {width: 100, label: 'TVM编号', prop: 'tvmCode', type: 'input', hide: false, search: false},
      {label: "实点金额", prop: "actualAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'actualAmount');
        }},
      {label: "系统金额", prop: "systemAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'systemAmount');
        }},
      {label: "差异金额", prop: "differenceAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'differenceAmount');
        }},
      {label: "售票员", prop: "conductorPersonName",type:'select',search:true,searchslot:true},
      {label: "员工号", prop: "conductorPersonCode"},
      {label: "流程状态", prop: "auditSate",type:'select',dicData:allStatus['audit_sate'],search:true,
        formatter:function (row,v) {
          return getAudit_state('audit_sate',v);
        }},
      {label: "是否补款",hide: true, prop: "isSupPayment",type:'select',dicData:supp_state_status(),formatter:function (row,v) {
          return getSupp_state_status(v);
        }},
      {label: "下发时间", prop: "sendTime",type:'date',format:'yyyy-MM-dd HH:mm:ss',valueFormat:'yyyy-MM-dd HH:mm:ss',width: 90},
      {label: "备注", prop: "remark",hide: true},
      {label: "收益审核意见", prop: "appealReply",hide: true},
    ]
  }
}

export function getDeptTvmPiaoKuanCYTZOption() {
  return {
    emptyBtn: false,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    border: true,
    index: true,
    indexLabel: '序号',
    page: true,
    align: 'center',
    menuWidth: 150,
    menuAlign: 'center',
    selection: true,
    reserveSelection: false,
    height: 450,
    column: [{label: "线路", prop: "lineCode",search:false,hide:true,searchslot:true,formatter: function(row, value , label, column){
        return getLineName(value);
      }},

      {label: "站点", prop: "stationCode",search:true,searchslot:true,formatter: function(row, value , label, column){
          return getStationName(row.lineCode,value);
        }},
      {label: "收入日期", prop: "recordTime",type:'date',
        width: 90,format:'yyyy-MM-dd',valueFormat:'yyyy-MM-dd'},
      {width: 100, label: 'TVM编号', prop: 'tvmCode', type: 'input', hide: false, search: false},
      {label: "实点金额", prop: "actualAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'actualAmount');
        }},
      {label: "系统金额", prop: "systemAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'systemAmount');
        }},
      {label: "差异金额", prop: "differenceAmount",formatter:function (row,v) {
          return fenExYuangettoFixed(row,'differenceAmount');
        }},
      {label: "流程状态", prop: "auditSate",type:'select',dicData:allStatus['audit_sate'],search:true,
        formatter:function (row,v) {
          return getAudit_state('audit_sate',v);
        }},
      {label: "售票员", prop: "conductorPersonName",type:'select',search:false,searchslot:true},
      {label: "员工号", prop: "conductorPersonCode"},
      {label: "申诉状态", prop: "appealStatus",type:'select',hide:true, dicData:getMappingStatusArray('car_appeal_status'),search:false,formatter:function (row,v) {
          return getMappingStatus('car_appeal_status',v);
        }},
      {label: "是否补款", hide: true,prop: "isSupPayment",type:'select',formatter:function (row,v) {
          return getIs_sup_payment(v);
        }},
      {label: "下发时间", prop: "sendTime",type:'date',format:'yyyy-MM-dd HH:mm:ss',valueFormat:'yyyy-MM-dd HH:mm:ss',width: 90},
    ]
  }
}


export function auditSwAuTvmrNotice(obj){
  return request({
    url: '/check/swautvmnotice/auditSwAuTvmrNotice',
    method: 'post',
    params: obj,
    data:obj,
  })
}

export function subAuditSwAuTvmNotice(id) {
  return request({
    url: '/check/swautvmnotice/subAuditSwAuTvmNotice',
    method: 'post',
    params: id,
    data:id,
  })
}

export function recallAppealSwAuTvmNotice(query) {
  return request({
    url: '/check/swautvmnotice/recallAppealSwAuTvmNotice',
    method: 'post',
    params: query,
    data:query,
  })
}

export function recallTvmNotice(query) {
  return request({
    url: '/check/swautvmnotice/recallTvmNotice',
    method: 'post',
    params: query,
    data:query,
  })
}

export function updateSwAuTvmNotice(query) {
  return request({
    url: '/check/swautvmnotice/updateSwAuTvmNotice',
    method: 'post',
    // params: query,
    data:query,
  })
}

export function affirmSwAuTvmNotice(query) {
  return request({
    url: '/check/swautvmnotice/affirmSwAuTvmNotice',
    method: 'post',
    params: query,
    data:query,
  })
}

export function getSwAuTvmNoticeList(query) {
  return request({
    url: '/check/swautvmnotice/getSwAuTvmNoticeList',
    method: 'post',
    params: query,
    data:query,
  })
}

export function fetchList(query) {
  return request({
    url: '/check/swautvmnotice/page',
    method: 'post',
    params: query
  })
}

export function addObj(obj) {
  return request({
    url: '/check/swautvmnotice',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: '/check/swautvmnotice/' + id,
    method: 'get'
  })
}

export function delObj(query) {
  return request({
    url: '/check/swautvmnotice/removeByIds',
    method: 'get',
    params: query
  })
}

export function putObj(obj) {
  return request({
    url: '/check/swautvmnotice',
    method: 'put',
    data: obj
  })
}

export function sendStatusUpdate(obj) {
  return request({
    url: '/check/swautvmnotice/sendStatusUpdate',
    method: 'post',
    data: obj
  })
}

/**
 * 审批申诉回复
 * @param query
 */
export function setAppealReply(query) {
  return request({
    url: '/check/swautvmnotice/setAppealReply',
    method: 'post',
    params: query
  })
}
